<template>
  <section>
      <el-card class="btn-card">
          <el-button type="info" v-if="baseInfo.userType==='dealer'">申请资金账号</el-button>
          <el-button type="danger" @click="deny">审核拒绝</el-button>
          <el-button type="success" @click="active">审核通过</el-button>
          <el-button class="returnBtn" @click="back">返回</el-button>
      </el-card>
      <el-collapse v-model="activeNames">
        <el-collapse-item title="基本资料" name="1">
          <el-form>
            <el-row>
              <el-col :span="12">
                <el-form-item label="商户编号">
                <label>{{baseInfo.code}}</label>
                </el-form-item>
                <el-form-item label="联系人">
                  <label> {{baseInfo.username}}</label>
                </el-form-item>
                <el-form-item label="手机号">
                  <label> {{baseInfo.phoneNormalized}}</label>
                </el-form-item>
                <el-form-item label="资金账号状态">
                  <label> {{baseInfo.ledgerStatusText}}</label>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="状态">
                  <label> {{baseInfo.status}}</label>
                </el-form-item>
                <el-form-item label="城市">
                  <label> {{baseInfo.cityName}}</label>
                </el-form-item>
                <el-form-item label="类型">
                  <label> {{baseInfo.userTypeName}}</label>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-collapse-item>
        <el-collapse-item title="个人资料" name="2">
          <el-form>
            <el-row>
                <el-form-item label="身份证号">{{baseInfo.idCardNumber}}</el-form-item>
              <el-col :span="12">
                <el-form-item label="身份证照片">
                  <img v-if="!!baseInfo.idCardPicture" :src="baseInfo.idCardPicture">
                  <label v-else>无</label>
                </el-form-item>
                <el-form-item label="银行卡照片">
                  <img v-if="!!baseInfo.bankCardPicture" :src="baseInfo.bankCardPicture">
                  <label v-else>无</label>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="身份证背面照片">
                  <img v-if="!!baseInfo.idCardBackPicture" :src="baseInfo.idCardBackPicture">
                  <label v-else>无</label>
                </el-form-item>
                <el-form-item label="银行卡背面照片">
                  <img v-if="!!baseInfo.bankCardBackPicture" :src="baseInfo.bankCardPicture">
                  <label v-else>无</label>
                </el-form-item>
              </el-col>

                <el-form-item label="手持身份证照片">
                  <img v-if="!!baseInfo.personPhoto" :src="baseInfo.bankCardPicture">
                  <label v-else >无</label>
                </el-form-item>
            </el-row>
          </el-form>
        </el-collapse-item>
      <el-collapse-item title="基本资料" name="3">
        <el-form>
          <el-row>
            <el-col :span="12">
              <el-form-item label="营业执照编号">{{baseInfo.business_licence_number}}</el-form-item>
              <el-form-item label="营业执照图片">
                <img v-if="!!baseInfo.businessLicencePicture" :src="baseInfo.businessLicencePicture">
                <label v-else>无</label>
              </el-form-item>
              <el-form-item label="工商证照片">
                <img v-if="!!baseInfo.businessCertPicture" :src="baseInfo.businessCertPicture">
                <label v-else>无</label>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="法人">{{baseInfo.legalPerson}}</el-form-item>
              <el-form-item label="组织机构代码证照片">
                <img v-if="!!baseInfo.orgCodePicture" :src="baseInfo.orgCodePicture">
                <label v-else>无</label>
              </el-form-item>
              <el-form-item label="税务登记证照片">
                <img v-if="!!baseInfo.taxRegPicture" :src="baseInfo.taxRegPicture">
                <label v-else>无</label>
              </el-form-item>
            </el-col>
              <el-form-item label="银行开户许可证照片">
                <img v-if="!!baseInfo.bankLisencePicture" :src="baseInfo.bankLisencePicture">
                <label v-else>无</label>
              </el-form-item>
          </el-row>
        </el-form>
      </el-collapse-item>
    </el-collapse>

  </section>
</template>
<style>
.returnBtn{
 float:right;
}

</style>
<script>

    export default{
        created(){
           this.loadGridData()
        },
        data(){
            return{
               activeNames: ['1','2','3'],
               baseInfo:{
                  code:'',
                  username:'',
                  phoneNormalized:'',
                  status:'',
                  cityName:'',
                  ledgerStatus:'',
                  ledgerStatusText:'',
                  userType:'',
                  userTypeName:'',
                  idCardNumber:'',
                  idCardPicture:'',
                  idCardBackPicture:'',
                  bankCardPicture:'',
                  bankCardBackPicture:'',
                  personPhoto:'',
                  businessLicenceNumber:'',
                  legalPerson:'',
                  businessLicencePicture:'',
                  businessCertPicture:'',
                  orgCodePicture:'',
                  taxRegPicture:'',
                  bankLisencePicture:''
               }
            }
        },
        methods:{
          loadGridData(){
            let userId=this.$route.params.id
            this.axios.get(`users/${userId}`).then(response=>{this.baseInfo=response.data})
          },
          back(){
            this.$router.push("/users")
          },
          deny(){
          },
          active(){
            let userId=this.$route.params.id
            this.axios.patch(`users/${userId}/activate`).then(()=>this.$notify({
									title: '成功',
									message: '提交成功',
									type: 'success'
								})).then(()=>this.loadGridData())
          },
          deny(){
            let userId=this.$route.params.id
            this.axios.patch(`users/${userId}/deny`).then(()=>this.$notify({
									message: '已拒绝申请',
									type: 'warning'
								})).then(()=>this.loadGridData())
          }
        }

    }

</script>
